<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>serializer</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.JSON">
<link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2">
<link rel="prev" href="boost__json__polymorphic_allocator.html" title="polymorphic_allocator">
<link rel="next" href="boost__json__serializer/reset.html" title="serializer::reset">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__polymorphic_allocator.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__serializer/reset.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="json.ref.boost__json__serializer"></a><a class="link" href="boost__json__serializer.html" title="serializer">serializer</a>
</h4></div></div></div>
<p>
        A serializer for JSON.
      </p>
<h5>
<a name="json.ref.boost__json__serializer.h0"></a>
        <span class="phrase"><a name="json.ref.boost__json__serializer.synopsis"></a></span><a class="link" href="boost__json__serializer.html#json.ref.boost__json__serializer.synopsis">Synopsis</a>
      </h5>
<p>
        Defined in header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json/serializer.hpp" target="_top">boost/json/serializer.hpp</a>&gt;</code>
      </p>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">serializer</span>
</pre>
<h5>
<a name="json.ref.boost__json__serializer.h1"></a>
        <span class="phrase"><a name="json.ref.boost__json__serializer.member_functions"></a></span><a class="link" href="boost__json__serializer.html#json.ref.boost__json__serializer.member_functions">Member
        Functions</a>
      </h5>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Name
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__serializer/done.html" title="serializer::done">done</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Returns <code class="computeroutput"><span class="keyword">true</span></code> if the
                  serialization is complete.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__serializer/read.html" title="serializer::read">read</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Read the next buffer of serialized JSON.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__serializer/reset.html" title="serializer::reset">reset</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Reset the serializer for a new element. <br> <span class="silver">—</span><br>
                  Reset the serializer for a new string.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__serializer/serializer.html" title="serializer::serializer">serializer</a> <span class="silver">[constructor]</span></strong></span>
                </p>
              </td>
<td>
                <p>
                  Move constructor (deleted) <br> <span class="silver">—</span><br>
                  Default constructor.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__serializer/_serializer.html" title="serializer::~serializer">~serializer</a> <span class="silver">[destructor]</span></strong></span>
                </p>
              </td>
<td>
                <p>
                  Destructor.
                </p>
              </td>
</tr>
</tbody>
</table></div>
<h5>
<a name="json.ref.boost__json__serializer.h2"></a>
        <span class="phrase"><a name="json.ref.boost__json__serializer.description"></a></span><a class="link" href="boost__json__serializer.html#json.ref.boost__json__serializer.description">Description</a>
      </h5>
<p>
        This class traverses an instance of a library type and emits serialized JSON
        text by filling in one or more caller-provided buffers. To use, declare a
        variable and call <a class="link" href="boost__json__serializer/reset.html" title="serializer::reset"><code class="computeroutput"><span class="identifier">reset</span></code></a> with a pointer to the variable
        you want to serialize. Then call <a class="link" href="boost__json__serializer/read.html" title="serializer::read"><code class="computeroutput"><span class="identifier">read</span></code></a> over and over until <a class="link" href="boost__json__serializer/done.html" title="serializer::done"><code class="computeroutput"><span class="identifier">done</span></code></a> returns <code class="computeroutput"><span class="keyword">true</span></code>.
      </p>
<h5>
<a name="json.ref.boost__json__serializer.h3"></a>
        <span class="phrase"><a name="json.ref.boost__json__serializer.example"></a></span><a class="link" href="boost__json__serializer.html#json.ref.boost__json__serializer.example">Example</a>
      </h5>
<p>
        This demonstrates how the serializer may be used to print a JSON value to
        an output stream.
      </p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">print</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&amp;</span> <span class="identifier">os</span><span class="special">,</span> <span class="identifier">value</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">jv</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">serializer</span> <span class="identifier">sr</span><span class="special">;</span>
    <span class="identifier">sr</span><span class="special">.</span><span class="identifier">reset</span><span class="special">(</span> <span class="special">&amp;</span><span class="identifier">jv</span> <span class="special">);</span>
    <span class="keyword">while</span><span class="special">(</span> <span class="special">!</span> <span class="identifier">sr</span><span class="special">.</span><span class="identifier">done</span><span class="special">()</span> <span class="special">)</span>
    <span class="special">{</span>
        <span class="keyword">char</span> <span class="identifier">buf</span><span class="special">[</span> <span class="number">4000</span> <span class="special">];</span>
        <span class="identifier">os</span> <span class="special">&lt;&lt;</span> <span class="identifier">sr</span><span class="special">.</span><span class="identifier">read</span><span class="special">(</span> <span class="identifier">buf</span> <span class="special">);</span>
    <span class="special">}</span>
<span class="special">}</span>
</pre>
<h5>
<a name="json.ref.boost__json__serializer.h4"></a>
        <span class="phrase"><a name="json.ref.boost__json__serializer.thread_safety"></a></span><a class="link" href="boost__json__serializer.html#json.ref.boost__json__serializer.thread_safety">Thread
        Safety</a>
      </h5>
<p>
        The same instance may not be accessed concurrently.
      </p>
<p>
        Convenience header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json.hpp" target="_top">boost/json.hpp</a>&gt;</code>
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2019, 2020 Vinnie Falco<br>Copyright © 2020 Krystian Stasiowski<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__polymorphic_allocator.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__serializer/reset.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
